<template>
  <div class="panel-phone">
    <el-form ref="formRef" :model="formData" label-width="60" size="large" :rules="rules" status-icon>
      <el-form-item label="手机号" prop="name">
        <el-input v-model="formData.phone" />
      </el-form-item>
      <el-form-item label="验证码" prop="code">
        <div class="verify-code">
          <el-input  v-model="formData.code" />
          <el-button class="get-code-btn">获取验证码</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import type { FormRules } from 'element-plus'

const formData = reactive({
  phone: '',
  code: ''
})

const rules: FormRules = {
  phone: [
    { required: true, message: '请输入手机号', trigger: 'blur' },
    { min: 11, max: 11, message: '手机号长度为11位', trigger: 'blur' }
  ],
  code: [
    { required: true, message: '请输入验证码', trigger: 'blur' },
    { min: 6, max: 6, message: '验证码长度为6位', trigger: 'blur' }
  ]
}
</script>

<style lang="less" scoped>
.panel-phone {
  .verify-code {
    display: flex;
    .get-code-btn {
      margin-left: 8px;
    }
  }
}
</style>
